home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / PowerPlant / CPullAppToFront / CPullAppToFront.cp next >
Encoding:
Text File  |  1996-09-14  |  3.0 KB  |  84 lines  |  [TEXT/R*ch]

  1. // ===========================================================================
  2. //    File:                        CPullAppToFront.cp
  3. // Version:                    1.0 - May 7, 1996
  4. //    Author:                    Mike Shields (mshields@inconnect.com)
  5. //                            
  6. //    Copyright ©1996 Mike Shields. All rights reserved.
  7. //    I hereby grant users of CPullAppToFront permission to use it (or any modified 
  8. //    version of it) in applications (or any other type of Macintosh software 
  9. //    like extensions -- freeware, shareware, commercial, or other) for free, 
  10. //    subject to the terms that:
  11. //
  12. //        (1)  This agreement is non-exclusive.
  13. //
  14. //        (2)  I, Mike Shields, retain the copyright to the original source code.
  15. //
  16. //    These two items are the only required conditions for use. However, I do have 
  17. //    an additional request. Note, however, that this is only a request, and 
  18. //    that it is not a required condition for use of this code.
  19. //
  20. //        (1) That I be given credit for CPullAppToFront code in the copyrights or 
  21. //            acknowledgements section of your manual or other appropriate documentation.
  22. //
  23. //
  24. //    I would like to repeat that this last item is only a request. You are prefectly 
  25. //    free to choose not to do any or all of them.
  26. //    
  27. //        This source code is distributed in the hope that it will be useful,
  28. //        but WITHOUT ANY WARRANTY; without even the implied warranty of
  29. //        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  30. // ===========================================================================
  31. //    CPullAppToFront.h        <- double-click + Command-D to see class declaration
  32. //
  33. // LPeriodical derived class which will make the application the frontmost
  34. // app when it executes. It will then delete itself.
  35.  
  36. #include "CPullAppToFront.h"
  37.  
  38. #ifndef __PROCESSES__
  39. #include <Processes.h>
  40. #endif
  41.  
  42. //---------------------------------------------------------------------------
  43. // CPullAppToFront::CPullAppToFront
  44. //---------------------------------------------------------------------------
  45. //    Default constructor
  46. CPullAppToFront::CPullAppToFront()
  47. {
  48. }
  49.  
  50.  
  51. //---------------------------------------------------------------------------
  52. // CPullAppToFront::~CPullAppToFront
  53. //---------------------------------------------------------------------------
  54. //    Destructor
  55. CPullAppToFront::~CPullAppToFront()
  56. {
  57. }
  58.  
  59. //---------------------------------------------------------------------------
  60. // CPullAppToFront::SpendTime
  61. //---------------------------------------------------------------------------
  62. //    Execute our periodical action (which is to delete ourselves)!
  63. void CPullAppToFront::SpendTime(const EventRecord &inMacEvent)
  64. {
  65.     StopRepeating();
  66.     
  67.     ProcessSerialNumber    currentPSN;
  68.     if ( ::GetCurrentProcess(¤tPSN) == noErr )
  69.         ::SetFrontProcess(¤tPSN);
  70.  
  71.     SpendTimeSelf(inMacEvent);
  72.     
  73.     delete this;
  74. }
  75.  
  76. //---------------------------------------------------------------------------
  77. // CPullAppToFront::DoIt
  78. //---------------------------------------------------------------------------
  79. //    Execute our periodical action (which is to delete ourselves)!
  80. void CPullAppToFront::SpendTimeSelf(const EventRecord &/*inMacEvent*/)
  81. {
  82. }
  83.  
  84.